//
//  Alert.m
//  OnlyComic
//
//  Created by dllo on 15/8/24.
//  Copyright (c) 2015年 liuchunling. All rights reserved.
//

#import "Alert.h"

@interface Alert ()

@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UILabel *label;

@end

@implementation Alert

- (void)dealloc
{
    [_imageView release];
    [_label release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame LabelText:(NSString *)labelText
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createAlert:labelText];
    }
    return self;
}

- (void)createAlert:(NSString *)labelText
{
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
    self.layer.cornerRadius = 10;
    
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    _label.text = labelText;
    _label.textColor = [UIColor whiteColor];
    _label.font = [UIFont systemFontOfSize:15];
    _label.textAlignment = NSTextAlignmentCenter;
    _label.numberOfLines = 0;
    [self addSubview:_label];
    [_label release];
    
    [UIView animateWithDuration:0.5 animations:^{
        
        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y - 200, self.frame.size.width, self.frame.size.height);
         self.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
    } completion:^(BOOL finished) {
        
        [UIView animateWithDuration:0.5 animations:^{
            
            self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.1];
        } completion:^(BOOL finished) {
            
            [self removeFromSuperview];
        }];
    }];
}

@end
